//
//  TRSendWebViewController.m
//  WeiMiLan
//
//  Created by Mac on 14-9-3.
//  Copyright (c) 2014年 Mac. All rights reserved.
//

#import "TRSendWebViewController.h"

@interface TRSendWebViewController ()<UIWebViewDelegate>

@end

@implementation TRSendWebViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

-(void)webViewDidFinishLoad:(UIWebView *)webView{
    [QLMaskUtil hideLoadingMaskWithView:self.webView];
    if (self.userId) {
        NSString *t = [webView stringByEvaluatingJavaScriptFromString:@"document.title"];
        self.weChatNavigationBar.titleLabel.text = t;
    }
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self initNavigation];
    self.webView.delegate = self;
    
    self.webView.scalesPageToFit =YES;
    NSURL *url;
    if (!self.pushUrl) {
        url=[NSURL URLWithString:@"http://www.vsmu.cn/sc.html"];
       
    }else{
        url = self.pushUrl;
    }
    
    NSURLRequest *request=[[NSURLRequest alloc] initWithURL:url];
    [QLMaskUtil showMaskLoadingWithView:self.webView];
    [self.webView loadRequest:request];
}

- (void)initNavigation
{
    [self.navigationController setNavigationBarHidden:YES animated:YES];
    self.weChatNavigationBar=[[WeChatNavigationBar alloc] init];
    [self.view addSubview:self.weChatNavigationBar];
    
    if ([NSString isBlankString:self.title]) {
        self.weChatNavigationBar.titleLabel.text=@"上传要求说明";
    }else{
        self.weChatNavigationBar.titleLabel.text=self.title;
    }
    
    [self.weChatNavigationBar.rightButton setImage:nil forState:0];
    if (self.userId) {
//        self.weChatNavigationBar.rightButton.titleLabel.font = [UIFont systemFontOfSize:15];
//        [self.weChatNavigationBar.rightButton setTitle:@"联系他" forState:UIControlStateNormal];
//        [self.weChatNavigationBar.rightButton sizeToFit];
//        [self.weChatNavigationBar.rightButton addTarget:self action:@selector(buttonConnectAction:)  forControlEvents:UIControlEventTouchUpInside];
    }
    
    [self.weChatNavigationBar.leftButton addTarget:self action:@selector(exit)  forControlEvents:UIControlEventTouchUpInside];
   
}

- (void)buttonConnectAction:(id)sender
{
    
}

-(void)exit
{
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
    [self.navigationController popViewControllerAnimated:YES];
}



@end
